<template>
	<view>
		<view class="content">
			<view class="li">
				<view class="li_1">
					昵称
				</view>
				<input type="text" v-model="nickname"  placeholder="请输入昵称"/>
			</view>
			<view class="queding" @click="Onqueding">
				<view>
					确定
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {profile,login} from '@/request/api.js'
	export default {
		data() {
			return {
				nickname:'',
				user_id:'',
			}
		},
		onLoad() {
			this.nickname = uni.getStorageSync("login").nickname
			this.user_id = uni.getStorageSync("login").id
		},
		methods: {
			Onqueding(){
				profile({
					nickname:this.nickname,
					user_id:this.user_id,
					type:"2",
				}).then(res => {
					console.log(res);
					uni.showToast({
						title: res.msg,
						icon: "none"
					})
					if(res.code == 1){
						let a = uni.getStorageSync('mobile')
						let b = uni.getStorageSync('password')
						let data={
							account:a,
							password:b,
							type:2
						}
						login(data).then(res=>{
							console.log(res,"登录登录")
							uni.setStorageSync('login',res.data)
							setTimeout(function(){
								let pages = getCurrentPages()//页面栈
								    let prePage = pages[pages.length - 2]//上一页
								    prePage.$vm.reFresh = Math.random()//触发上一页监听器
								    uni.navigateBack()//返回上一页
							},600)
						}).catch(err=>{
							
						})
					}
				})
			}
		}
	}
</script>

<style  lang="scss">
	.queding{
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 200rpx;
		view{
			width: 340rpx;
			height: 80rpx;
			line-height: 80rpx;
			border-radius: 1000px;
			background: #1855F6;
			font-size: 30rpx;
			color: #fff;
			text-align: center;
		}
	}
	.li{
		padding: 33rpx 40rpx;
		display: flex;
		align-items: center;
		border-top: 1px solid rgba(211, 213, 220, 0.4);
		border-bottom: 1px solid rgba(211, 213, 220, 0.4);
		.li_1{
			width: 220rpx;
		}
	}
	
</style>
